package com.ld.exception;


import com.ld.emun.ErrorCodeEnum;
import lombok.Getter;

@Getter
public class BusinessException extends RuntimeException {

    private long code;

    private String message;

    public BusinessException(ErrorCodeEnum errorCodeEnum) {
        this.code = errorCodeEnum.getCode();
        this.message = errorCodeEnum.getMessage();
    }

    public BusinessException(String errorMsg) {
        this.code = ErrorCodeEnum.UNKNOWN_ERROR.getCode();
        this.message = errorMsg;
    }


    public BusinessException(ErrorCodeEnum errorCodeEnum, Object... o) {
        this.code = errorCodeEnum.getCode();
        this.message = String.format(errorCodeEnum.getMessage(), o);
    }

}
